package com.mall.web.controller.course.admin;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.mall.course.swimPlace.domain.dto.SwimPlaceDto;
import com.mall.course.swimPlace.domain.vo.SwimPlaceVo;
import com.mall.course.swimPlace.service.ISwimPlaceService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mall.common.annotation.Log;
import com.mall.common.core.controller.BaseController;
import com.mall.common.core.domain.AjaxResult;
import com.mall.common.enums.BusinessType;
import com.mall.common.utils.poi.ExcelUtil;
import com.mall.common.core.page.TableDataInfo;

/**
 * 游泳馆Controller
 * 
 * @author mall
 * @date 2024-05-18
 */
@RestController
@RequestMapping("/admin/course/swimPlace")
public class SwimPlaceController extends BaseController
{
    @Autowired
    private ISwimPlaceService swimPlaceService;

    /**
     * 查询游泳馆列表
     */
    @PreAuthorize("@ss.hasPermi('course:swimPlace:list')")
    @GetMapping("/list")
    public TableDataInfo list(SwimPlaceDto swimPlaceDto)
    {
        startPage();
        List<SwimPlaceVo> list = swimPlaceService.selectSwimPlaceList(swimPlaceDto);
        return getDataTable(list);
    }

    /**
     * 导出游泳馆列表
     */
    @PreAuthorize("@ss.hasPermi('course:swimPlace:export')")
    @Log(title = "游泳馆", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SwimPlaceDto swimPlace)
    {
        List<SwimPlaceVo> list = swimPlaceService.selectSwimPlaceList(swimPlace);
        ExcelUtil<SwimPlaceVo> util = new ExcelUtil<SwimPlaceVo>(SwimPlaceVo.class);
        util.exportExcel(response, list, "游泳馆数据");
    }

    /**
     * 获取游泳馆详细信息
     */
    @PreAuthorize("@ss.hasPermi('course:swimPlace:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(swimPlaceService.selectSwimPlaceById(id));
    }

    /**
     * 新增游泳馆
     */
    @PreAuthorize("@ss.hasPermi('course:swimPlace:add')")
    @Log(title = "游泳馆", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SwimPlaceDto swimPlaceDto)
    {
        return toAjax(swimPlaceService.insertSwimPlace(swimPlaceDto));
    }

    /**
     * 修改游泳馆
     */
    @PreAuthorize("@ss.hasPermi('course:swimPlace:edit')")
    @Log(title = "游泳馆", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SwimPlaceDto swimPlaceDto)
    {
        return toAjax(swimPlaceService.updateSwimPlace(swimPlaceDto));
    }

    /**
     * 删除游泳馆
     */
    @PreAuthorize("@ss.hasPermi('course:swimPlace:remove')")
    @Log(title = "游泳馆", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(swimPlaceService.deleteSwimPlaceByIds(ids));
    }
}
